package cate.game.role.login;

import easy.java.dev.note.NoteField;
import org.apache.commons.lang3.StringUtils;

/** 角色登录数据处理 */
public class RoleLogin {

    @NoteField("登录IP")
    public String ip;

    @NoteField("客户端类型")
    public String clientType;

    @NoteField(value = "冻结时间直到")
    private long banUntil;

    @NoteField(value = "冻结原因")
    private String banReason;

    public void ban(long until, String reason) {
        this.banUntil = until;
        this.banReason = reason;
    }

    /** 是否禁止登陆 */
    public boolean isBanned() {
        return System.currentTimeMillis() < this.banUntil;
    }

    public String getBanReason() {
        if(StringUtils.isBlank(this.banReason)) {
            return "role has been banned from login";
        }
        return this.banReason;
    }
}
